package cn.javacart.jfinal.php.render;

import com.jfinal.plugin.IPlugin;

public class PhpEnvPlugin implements IPlugin{

	private boolean devMode = false;
	
	private String basePath = null;
	
	/**
	 * 对象池最大对象数
	 */
	private static int DEFAULT_MAXACTIVE = 32;
	/**
	 * 最大空闲数
	 */
	private static int DEFAULT_MAXIDLE = 16;
	/**
	 * 最大超时时间
	 */
	private static long DEFAULT_MAXWAIT = 6*1000;
	
	/**
	 * 对象池最大对象数
	 */
	private int maxActive = DEFAULT_MAXACTIVE;
	/**
	 * 最大空闲数
	 */
	private int maxIdle = DEFAULT_MAXIDLE;
	/**
	 * 最大超时时间
	 */
	private long maxWait = DEFAULT_MAXWAIT;
	
	public PhpEnvPlugin(boolean devMode,String basePath) {
		this(devMode, basePath, DEFAULT_MAXACTIVE, DEFAULT_MAXIDLE, DEFAULT_MAXWAIT);
	}
	
	public PhpEnvPlugin(boolean devMode,String basePath,int maxActive ,int maxIdle,long maxWait) {
		this.devMode = devMode;
		this.basePath = basePath;
		this.maxActive = maxActive;
		this.maxIdle = maxIdle;
		this.maxWait = maxWait;
	}
	
	
	@Override
	public boolean start() {
		PhpEnvKit.init(devMode,basePath,maxActive,maxIdle,maxWait);
		return true;
	}

	@Override
	public boolean stop() {
		return true;
	}

}
